#include <cstdio>

using namespace std;
int numbers[100001], dp[100001];
int main()
{
    int T, n, i, max = 0;
    scanf("%d", &T);
    while (T--)
    {
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
        {
            scanf("%d", &numbers[i]);
        }
        dp[0] = numbers[0];
        max = -0x7fff;
        for (int i = 0; i < n; i++)
        {
            if (dp[i - 1] + numbers[i] >= numbers[i])
            {
                dp[i] = dp[i - 1] + numbers[i];
            }
            else
            {
                dp[i] = numbers[i];
            }
            if (max < dp[i])
            {
                max = dp[i];
            }
        }
        printf("%d", max);
        if(T != 0)
        {
            printf("\n");
        }
    }
    return 0;
}